package com.cloud.bc.controller.pc;

import com.cloud.bc.controller.BaseController;
import com.cloud.bc.model.domain.UserInfo;
import com.cloud.bc.model.entity.BcUserPhotos;
import com.cloud.bc.model.enums.PhotoEnum;
import com.cloud.bc.service.BcUserPhotosService;
import com.cloud.bc.service.BcUsersService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

//PC单身中心资料
@Controller
@AllArgsConstructor
@RequestMapping("center/photo")
public class PcCenterPhotoController extends BaseController {
    private final BcUsersService bcUsersService;
    private final BcUserPhotosService bcUserPhotosService;


    /**
     * 我的相册
     */
    @GetMapping("")
    public ModelAndView index(HttpServletRequest request, HttpServletResponse response) {
        ModelAndView view = baseView(request,"我的相册-用户中心", "pc/center/photo/index");
        UserInfo userInfo = bcUsersService.getUserInfo(request);

        BcUserPhotos bcUserPhotos = new BcUserPhotos();
        bcUserPhotos.setUserId(userInfo.getId());
        bcUserPhotos.setTitle(PhotoEnum.ALBUM.getTitle());
        List<BcUserPhotos> albumList = bcUserPhotosService.selectAll(bcUserPhotos);
        view.addObject("photo", albumList);
        view.addObject("bodyCss", "page_manage page_manage_photo");
        return view;
    }

}
